package online.afeibaili.storebackendframework.repository

import online.afeibaili.storebackendframework.model.OrderEntity
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.data.jpa.repository.Query
import org.springframework.data.repository.query.Param
import org.springframework.stereotype.Repository


/**
 * 订单存储层
 *
 *@author AfeiBaili
 *@version 2025/10/17 16:00
 */

@Repository
interface OrderRepository : JpaRepository<OrderEntity, Long> {
    fun findByCreateTimeBetween(min: Long, max: Long): List<OrderEntity>

    @Query("select e from OrderEntity e where e.createTime between :min and :max and e.paymentStatus in (1,2)")
    fun findByCreateTimeBetweenAndPayed(@Param("min") min: Long, @Param("max") max: Long): List<OrderEntity>

    fun findByAccountId(accountId: String): List<OrderEntity>
}